"use strict";
cc._RF.push(module, 'f6c50EG6w1PDIKbNlPml9Hk', 'NativeAdHideTrigger');
// scripts/NativeAdHideTrigger.js

"use strict";

var e = require;
var t = module;
var n = exports;
Object.defineProperty(n, "__esModule", {
  value: !0
});

var o = e("NativeAd_Huawei"),
    i = e("NativeAd_Oppo"),
    a = e("NativeAd_Oppo_Android"),
    r = e("NativeAd_Vivo"),
    s = e("NativeAd_Xiaomi"),
    c = cc._decorator,
    l = c.ccclass,
    d = c.property,
    h = function (e) {
  __extends(t, e);

  function t() {
    var t = null !== e && e.apply(this, arguments) || this;
    t.waitKeyName = "nativeAdHideWait";
    t.scaleKeyName = "nativeAdHideScale";
    t.cdKeyName = "nativeAdHideCD";
    t.strongKeyName = "nativeAdHideStrong";
    t.triggerNode = null;
    t.cdTime = 60;
    t.nativeAd_Oppo = null;
    t.nativeAd_Vivo = null;
    t.nativeAd_Android_Oppo = null;
    t.nativeAd_Huawei = null;
    t.nativeAd_Xiaomi = null;
    t.nativeAd_Base = null;
    return t;
  }

  t.prototype.start = function () {
    var e = this;
    this.nativeAd_Oppo = this.getComponent(i["default"]);
    this.nativeAd_Vivo = this.getComponent(r["default"]);
    this.nativeAd_Android_Oppo = this.getComponent(a["default"]);
    this.nativeAd_Huawei = this.getComponent(o["default"]);
    this.nativeAd_Xiaomi = this.getComponent(s["default"]);
    SDK.Mgr.Inst.curChannel == SDK.Define.Channel.oppo ? this.nativeAd_Base = this.nativeAd_Oppo : SDK.Mgr.Inst.curChannel == SDK.Define.Channel.vivo ? this.nativeAd_Base = this.nativeAd_Vivo : SDK.Mgr.Inst.curChannel == SDK.Define.Channel.android_oppo ? this.nativeAd_Base = this.nativeAd_Android_Oppo : SDK.Mgr.Inst.curChannel == SDK.Define.Channel.huawei ? this.nativeAd_Base = this.nativeAd_Huawei : SDK.Mgr.Inst.curChannel == SDK.Define.Channel.xm && (this.nativeAd_Base = this.nativeAd_Xiaomi);
    this.triggerNode.on(cc.Node.EventType.TOUCH_START.toString(), this.btnClickStart, this);
    this.triggerNode.on(cc.Node.EventType.TOUCH_END.toString(), this.btnClickEnd, this);
    this.triggerNode.on(cc.Node.EventType.TOUCH_CANCEL.toString(), this.btnClickCancel, this);

    if (SDK.Mgr.Inst.isAdOpen && SDK.Mgr.Inst.customData) {
      if (SDK.Mgr.Inst.customData[this.waitKeyName]) this.scheduleOnce(function () {
        if (SDK.Mgr.Inst.customData[e.scaleKeyName]) {
          e.triggerNode.scaleX = SDK.Mgr.Inst.customData[e.scaleKeyName][0];
          e.triggerNode.scaleY = SDK.Mgr.Inst.customData[e.scaleKeyName][1];
          console.log("nativeAdHideTriggerScale", JSON.stringify(SDK.Mgr.Inst.customData[e.scaleKeyName]));
        }
      }, SDK.Mgr.Inst.customData[this.waitKeyName]);else if (SDK.Mgr.Inst.customData[this.scaleKeyName]) {
        this.triggerNode.scaleX = SDK.Mgr.Inst.customData[this.scaleKeyName][0];
        this.triggerNode.scaleY = SDK.Mgr.Inst.customData[this.scaleKeyName][1];
        console.log("nativeAdHideTriggerScale", JSON.stringify(SDK.Mgr.Inst.customData[this.scaleKeyName]));
      }

      if (SDK.Mgr.Inst.customData[this.cdKeyName]) {
        this.cdTime = SDK.Mgr.Inst.customData[this.cdKeyName];
        console.log("nativeAdHideTriggerCD", SDK.Mgr.Inst.customData[this.cdKeyName]);
      }
    }

    SDK.Mgr.Inst.curChannel == SDK.Define.Channel.oppo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.android_oppo || SDK.Mgr.Inst.curChannel == SDK.Define.Channel.xm ? this.triggerNode.active = !0 : this.triggerNode.active = !1;
  };

  t.prototype.onDestroy = function () {
    this.triggerNode.off(cc.Node.EventType.TOUCH_START.toString(), this.btnClickStart, this);
    this.triggerNode.off(cc.Node.EventType.TOUCH_END.toString(), this.btnClickEnd, this);
    this.triggerNode.off(cc.Node.EventType.TOUCH_CANCEL.toString(), this.btnClickCancel, this);
  };

  t.prototype.btnClickStart = function () {
    console.log("btnClickStart");
    this.btnClick();
  };

  t.prototype.btnClickEnd = function () {
    console.log("btnClickEnd");

    if (SDK.Mgr.Inst.isAdOpen && SDK.Mgr.Inst.customData && "true" == SDK.Mgr.Inst.customData[this.strongKeyName]) {
      console.log("btnClickEndTrigger");
      this.btnClick();
    }
  };

  t.prototype.btnClickCancel = function () {
    console.log("btnClickCancel");

    if (SDK.Mgr.Inst.isAdOpen && SDK.Mgr.Inst.customData && "true" == SDK.Mgr.Inst.customData[this.strongKeyName]) {
      console.log("btnClickCancelTrigger");
      this.btnClick();
    }
  };

  t.prototype.btnClick = function () {
    var e = this;
    this.nativeAd_Base && this.nativeAd_Base.click();

    if (SDK.Mgr.Inst.isAdOpen && SDK.Mgr.Inst.customData) {
      this.triggerNode.scale = 1;
      SDK.Mgr.Inst.customData[this.scaleKeyName] && this.scheduleOnce(function () {
        e.triggerNode.scaleX = SDK.Mgr.Inst.customData[e.scaleKeyName][0];
        e.triggerNode.scaleY = SDK.Mgr.Inst.customData[e.scaleKeyName][1];
      }, this.cdTime);
    }
  };

  __decorate([d(cc.Node)], t.prototype, "triggerNode", void 0);

  return __decorate([l], t);
}(cc.Component);

n["default"] = h;

cc._RF.pop();